"""
UndoCommand.py

This class is intended to represent an undo command.  undoMove handles
the correct execution of the undo function by looking at the element on
the move stack, and if a move can be undone, handles it. 

Author: Ryan Walters
Date: 10-12-08

$Id: UndoCommand.py 339 2008-10-17 03:57:13Z malerba89 $
"""

from Game import Game
from GameMove import GameMove
from Command import Command

class UndoCommand(Command):

    #Initialization, should be called with each new game
    def __init__(self, game):
        self.game = game

    # A function to handle undoing a move
    def execute(self):
        if self.game.get_last_move() is not None:
            turn = self.game.get_last_move().get_player()
        else:
            turn = None
        if turn is 'Maker' and turn is not None:
            print "Was a maker/breaker move undone."
            self.game.undo_last_move()
            self.game.undo_last_move()
        elif self.game.get_last_move() is not None:
            self.game.undo_last_move()
        else:
            pass


